package com.qingcloud.fexecutor.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 数据目录接口返回对象
 *
 * @author wangjinnan
 */
public class ApiDTO {

    private ApiDTO() {
    }

    /**
     * Api树形结构对象
     */
    @Getter
    @Setter
    public static class ApiTree implements Serializable {

        @ApiModelProperty(value = "分组Id", example = "")
        private String id;

        @ApiModelProperty(value = "分组名称", example = "")
        private String name;

        @ApiModelProperty(value = "所有Api")
        private List<ApiBase> children;
    }

    /**
     * Api树形结构对象
     */
    @Getter
    @Setter
    public static class ApiOption implements Serializable {

        @ApiModelProperty(value = "id", example = "")
        private String id;

        @ApiModelProperty(value = "Api名称", example = "")
        private String name;

        @ApiModelProperty(value = "请求方法", example = "")
        private String method;

    }

    /**
     * 分类树形结构对象
     */
    @Getter
    @Setter
    public static class ApiBase implements Serializable {

        @ApiModelProperty(value = "apiId", example = "")
        private Integer id;

        @ApiModelProperty(value = "api 名称", example = "")
        private String name;
    }

    /**
     * Api详情
     */
    @Getter
    @Setter
    public static class ApiDetail implements Serializable {

        @ApiModelProperty(value = "Api详情基本信息", example = "")
        ApiDetailBase apiDetailBase;

        @ApiModelProperty(value = "Head请求参数", example = "")
        List<ApiParameter> requestHeadParameterList;

        @ApiModelProperty(value = "Body请求参数", example = "")
        List<ApiParameter> requestBodyParameterList;

        @ApiModelProperty(value = "Query请求参数", example = "")
        List<ApiParameter> requestQueryParameterList;

        @ApiModelProperty(value = "Form请求参数", example = "")
        List<ApiParameter> requestFormParameterList;

        @ApiModelProperty(value = "Form请求参数", example = "")
        List<ApiParameter> requestPathParameterList;

        @ApiModelProperty(value = "响应请求参数", example = "")
        List<ApiParameter> responseParameterList;

        @ApiModelProperty(value = "Api文档", example = "")
        DocParameter docParameter;

        @ApiModelProperty(value = "JSON参数根类型 1-对象 2-数组(请求参数)", example = "")
        private Integer requestRootType;

        @ApiModelProperty(value = "JSON参数根类型 1-对象 2-数组(响应参数)", example = "")
        private Integer responseRootType;

    }

    @Getter
    @Setter
    public static class ApiDetailBase implements Serializable {

        @ApiModelProperty(value = "(保存状态为1-草稿)状态 1-草稿 2-已发布 3-停用", example = "")
        private Integer status;

        @ApiModelProperty(value = "API类型 1-静态API,2-动态API", example = "")
        private Integer type;

        @ApiModelProperty(value = "Api名称", example = "")
        private String name;

        @ApiModelProperty(value = "url", example = "")
        private String url;

        @ApiModelProperty(value = "请求方法 get post", example = "")
        private String method;

        @ApiModelProperty(value = "分组Id", example = "")
        private String groupId;

        @ApiModelProperty(value = "分组名称", example = "")
        private String groupName;

        @ApiModelProperty(value = "停服标识 1生效 2失效", example = "")
        private Boolean stopFlag;

        @ApiModelProperty(value = "停服周期 1-每天 2-每周 3-每月 4-每年", example = "")
        private Integer stopPeriod;

        @ApiModelProperty(value = "停服开始时间", example = "")
        private String stopStart;

        @ApiModelProperty(value = "停服截至时间", example = "")
        private String stopEnd;

        @ApiModelProperty(value = "创建人Id", example = "")
        private String createUser;

        @ApiModelProperty(value = "创建人名称", example = "")
        private String createUserName;

        @ApiModelProperty(value = "更新人Id", example = "")
        private String modifyUser;

        @ApiModelProperty(value = "更新人名称", example = "")
        private String modifyUserName;

        @ApiModelProperty(value = "更新时间", example = "")
        private String modifyTime;

    }

    @Getter
    @Setter
    public static class ApiParameter implements Serializable {

        @ApiModelProperty(value = "Id", example = "")
        private Integer Id;

        @ApiModelProperty(value = "类型 1-header 2-body 3-query", example = "")
        private Integer type;

        @ApiModelProperty(value = "JSON参数根类型 1-对象 2-数组(有就传没有就不传)", example = "")
        private Integer rootType;

        @ApiModelProperty(value = "所属ApiId(没有则不传)", example = "")
        private String apiId;

        @ApiModelProperty(value = "JSON节点ID", example = "")
        private String nodeId;

        @ApiModelProperty(value = "父级JSON ID", example = "")
        private String parentNodeId;

        @ApiModelProperty(value = "参数名称", example = "")
        private String key;

        @ApiModelProperty(value = "值类型", example = "")
        private Integer valueType;

        @ApiModelProperty(value = "默认参数值", example = "")
        private String defaultValue;

        @ApiModelProperty(value = "是否必填 0不 1是", example = "")
        private Boolean requiredFlag;

        @ApiModelProperty(value = "参数说明", example = "")
        private String comment;

        @ApiModelProperty(value = "子节点", example = "")
        private List<ApiParameter> children;

    }


    @Getter
    @Setter
    public static class DocParameter implements Serializable {

        @ApiModelProperty(value = "Id", example = "")
        private Integer Id;

        @ApiModelProperty(value = "所属ApiId", example = "")
        private Integer apiId;

        @ApiModelProperty(value = "数据源", example = "")
        private Integer dsId;

        @ApiModelProperty(value = "SQL中包含的表ID", example = "")
        private String tableIds;

        @ApiModelProperty(value = "动态API SQL", example = "")
        private String sql;

        @ApiModelProperty(value = "API文档", example = "")
        private String doc;

    }

    @Getter
    @Setter
    public static class ApiAuthor implements Serializable {

        @ApiModelProperty(value = "Id", example = "")
        private String Id;

        @ApiModelProperty(value = "调用方Id", example = "")
        private String customerId;

        @ApiModelProperty(value = "调用方名称", example = "")
        private String customerName;

        @ApiModelProperty(value = "api Id", example = "")
        private String apiId;

        @ApiModelProperty(value = "授权人", example = "")
        private String authUser;

        @ApiModelProperty(value = "授权人", example = "")
        private String authUserName;

        @ApiModelProperty(value = "授权时间", example = "")
        private String authTime;

        @ApiModelProperty(value = "授权截止时间", example = "")
        private String authEndTime;

    }

    @Getter
    @Setter
    public static class ApiPublish implements Serializable {

        @ApiModelProperty(value = "发布记录Id", example = "")
        private Integer Id;

        @ApiModelProperty(value = "api Id", example = "")
        private Integer apiId;

        @ApiModelProperty(value = "发布人Name", example = "")
        private String publishUserName;

        @ApiModelProperty(value = "发布时间", example = "")
        private String publishTime;

    }

    @Getter
    @Setter
    public static class ApiTest implements Serializable {

        @ApiModelProperty(value = "发布记录Id", example = "")
        private Integer Id;

        @ApiModelProperty(value = "api Id", example = "")
        private Integer apiId;

        @ApiModelProperty(value = "HTTP响应状态码", example = "")
        private Integer statusCode;

        @ApiModelProperty(value = "请求耗时，毫秒", example = "")
        private Integer spend;

        @ApiModelProperty(value = "响应内容字节", example = "")
        private BigDecimal size;

        @ApiModelProperty(value = "单位", example = "")
        private String unit;

        @ApiModelProperty(value = " 测试时间", example = "")
        private String test_time;

    }

    @Getter
    @Setter
    public static class ApiCall implements Serializable {

        @ApiModelProperty(value = "发布记录Id", example = "")
        private Integer Id;

        @ApiModelProperty(value = "api Name", example = "")
        private String apiName;

        @ApiModelProperty(value = "调用方名称", example = "")
        private String customerName;

        @ApiModelProperty(value = "Ip", example = "")
        private String clientIp;

        @ApiModelProperty(value = "请求数据量", example = "")
        private String size;

        @ApiModelProperty(value = "请求数据量单位", example = "")
        private String unit;

        @ApiModelProperty(value = "结果", example = "")
        private String result;

        @ApiModelProperty(value = "请求耗时，毫秒", example = "")
        private Integer spend;

        @ApiModelProperty(value = "原因", example = "")
        private String errorMsg;

        @ApiModelProperty(value = "调用时间", example = "")
        private String requestTime;

    }

}
